import celery

import os
# 执行django配置文件，环境变量加入
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "luffyapi.settings.dev")

broker = 'redis://127.0.0.1:6379/1'  # 1 表示使用redis 1 这个db

backend = 'redis://127.0.0.1:6379/2'  # 2 表示使用redis 2 这个db

app = celery.Celery('banner', broker=broker, backend=backend,
                    include=['celery_task.home_task', ]
                    )

# 时区
app.conf.timezone = 'Asia/Shanghai'
# 是否使用UTC
app.conf.enable_utc = False

# 任务的定时配置
from datetime import timedelta
from celery.schedules import crontab

app.conf.beat_schedule = {
    'update-banner': {
        'task': 'celery_task.home_task.update_banner',
        'schedule': timedelta(seconds=10),
        'args': (),
    }
}
